#ifndef UDPCOMM_H
#define UDPCOMM_H

#include "BaseComm.h"

#include <QUdpSocket>

class UdpComm : public BaseComm
{
    Q_OBJECT
public:
    explicit UdpComm(QObject* parent = nullptr);
    ~UdpComm();

    // 初始化通信
    virtual bool initialize() override;

    // 发送数据
    virtual int sendData(const QByteArray& data) override;

    // 接收数据
    virtual int recvData(QByteArray& data) override;

    // 启动通信
    virtual bool start() override;

    // 停止通信
    virtual bool stop() override;

private:
    QUdpSocket* socket;
    QString localIpAddr = "";
    quint16 localPort = 0;
    QString destIpAddr = "";
    quint16 destPort = 0;

};

#endif // UDPCOMM_H
